 %Create a class named neuron, placed in file 'neuron.m'
classdef neuron
    properties
        id;
        layer;
        threshold;
    end
    methods
        function obj = neuron(id, layer, threshold)
            obj.id = id;
            obj.layer = layer;
            obj.threshold = threshold;
        end
        function disp(obj)
            s = sprintf('Neuron #%d (layer: %d threshold: %.2f)', ...
                obj.id, obj.layer, obj.threshold);
            disp(s);
        end
        function output = Spike(obj, weightedInput)
            if(sum(weightedInput) >= obj.threshold)
                output = 1; %produce spike
            else
                output = 0; %do nothing
            end
        end
    end
end